﻿using ITPaloozaPCL.Interfaces;
using ITPaloozaPCL.PCL.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITPaloozaPCL.PCL.Service
{
    public class DataService
    {
        public List<IStock> GetPriceList(string symbol, int days)
        {
            Random priceCreator = new Random();
            double currentPrice = priceCreator.Next(100);

            List<IStock> returnValues = new List<IStock>();
            for (int x = 0; x < days; x++)
            {
                returnValues.Add(new Stock()
                {
                    Symbol = symbol,
                    High = (decimal)(currentPrice + priceCreator.NextDouble()),
                    Low = (decimal)(currentPrice - priceCreator.NextDouble()),
                    Close = (decimal)(currentPrice),
                    Open = (decimal)(currentPrice + priceCreator.NextDouble()),
                    Date = DateTime.Now.AddDays(-x),
                });
                if (x % 3 == 0)
                    currentPrice = currentPrice - priceCreator.NextDouble();
                else
                    currentPrice = currentPrice + priceCreator.NextDouble();
            }
            return returnValues;
        }
    }
}
